package com.itheima.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2020-08-11 09:37
 * @description
 *
 * 简化视图解析器使用 返回视图地址就可以了
 */


@Controller
@RequestMapping("/user04")
public class demo4_简化视图解析器使用 {

    //返回值改为String 省略了modelAndView的set,直接返回地址
    @RequestMapping("/login.do")
    public String login(Model model) throws ServletException, IOException {
        System.out.println("用户登录...");

        //响应信息

        //springmvc框架提供了对象
        model.addAttribute("info","模拟的登录数据");

        return "user/success";
    }

    @RequestMapping("/register.do")
    public String register(Model model) throws ServletException, IOException {
        System.out.println("用户注册...");

        model.addAttribute("info","模拟的注册数据");

        return "user/success";

    }

    @RequestMapping("/logout.do")
    public String logout(Model model) throws ServletException, IOException {
        System.out.println("退出登录...");

        model.addAttribute("info","模拟的推出登录数据");

        return "user/success";

    }
}
